﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ClientDW.Synchronization.RiskRatingsBenchmarks
{
    public class DoubleComparer : IComparer<double?>
    {
        private const double difference = 1e-16;
        public int Compare(double? x, double? y)
        {
            var dif = (x.GetValueOrDefault() - y.GetValueOrDefault());

            if (Math.Abs(dif) <= difference)
                return 0;

            if (dif > difference)
                return 1;

            return -1;

        }
    }
}